import argparse
import json
import os

if __name__ == '__main__':
    parser = argparse.ArgumentParser()
    parser.add_argument('--device', type=int, default=0)
    parser.add_argument('--model_path', type=str,
                        default="/root/AscendAtDL2PHY1/models/om_pytorch/torch.clamp/20221229_182151")
    parser.add_argument('--input_path', type=str,
                        default="/root/AscendAtDL2PHY1/dataset/pytorch/input/torch.clamp/20221229_182151")
    parser.add_argument('--seed_path', type=str,
                        default="/root/AscendAtDL2PHY1/dataset/pytorch/seed/torch.clamp/20221229_182151")
    parser.add_argument('--input_name', type=str,
                        default="torch.clamp_inputs.json")
    parser.add_argument('--seed_name', type=str,
                        default="torch.clamp_seeds.npz")
    parser.add_argument('--output_path', type=str,
                        default="/root/AscendAtDL2PHY1/model_inference/source")
    args = parser.parse_args()

    # batch execute test cases
    device = args.device
    model_path = args.model_path
    input_path = args.input_path
    seed_path = args.seed_path
    input_name = args.input_name
    seed_name = args.seed_name
    output_path = args.output_path

    full_input_path = os.path.join(args.input_path, args.input_name)
    with open(full_input_path, "r") as f:
        input_dict_list = json.load(f)
    for i in range(len(input_dict_list)):
        input_dict = input_dict_list[i]
        if len(input_dict["inputs"]) != 0:
            os.system("cd /root/AscendAtDL2PHY1/model_inference;"
                      "python3 acl_net.py --model_path=%s "
                      "--input_path=%s "
                      "--input_index=%d "
                      "--seed_path=%s "
                      "--input_name=%s "
                      "--seed_name=%s "
                      "--output_path=%s" % (model_path, input_path, i, seed_path, input_name, seed_name, output_path))
